// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: daniel

#pragma once

#include <string>
#include <string_view>

#include "quickfix/Log.h"
#include "quickfix/SessionSettings.h"

namespace coin2::exchange::base::api_base::fix {

/********************************************************************************
 * class CoinLogFactory                                                         *
 ********************************************************************************/
class CoinLogFactory : public FIX::LogFactory {
 public:
  explicit CoinLogFactory(const FIX::SessionSettings&);
  explicit CoinLogFactory(bool, bool, bool);

  FIX::Log* create();
  FIX::Log* create(const FIX::SessionID&);
  void destroy(FIX::Log*);

 private:
  void init(const FIX::Dictionary&, bool&, bool&, bool&);

  bool incoming_;
  bool outgoing_;
  bool event_;
  bool use_settings_;
  FIX::SessionSettings settings_;
};

/********************************************************************************
 * class CoinLogger                                                             *
 ********************************************************************************/
class FixCoinLogger : public FIX::Log {
 public:
  FixCoinLogger(bool, bool, bool);
  FixCoinLogger(const FIX::SessionID&, bool, bool, bool);

  void clear();
  void backup();

  void onIncoming(const std::string&);
  void onOutgoing(const std::string&);
  void onEvent(const std::string&);

 private:
  std::string prefix_;
  bool incoming_;
  bool outgoing_;
  bool event_;
};

}  // namespace coin2::exchange::base::api_base::fix
